package com.api.controller;

import com.api.model.dto.userInterfaceinfo.UserInterfaceInfoAddDTO;
import com.api.model.dto.userInterfaceinfo.UserInterfaceInfoQueryDTO;
import com.api.model.dto.userInterfaceinfo.UserInterfaceInfoUpdateDTO;
import com.api.model.entity.InterfaceInfo;
import com.api.model.entity.UserInterfaceInfo;
import com.api.model.reslut.Result;
import com.api.model.reslut.ResultPage;
import com.api.service.UserInterfaceInfoService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/user/info")
public class UserInterfaceInfoController {

    @Resource
    private UserInterfaceInfoService userInterfaceInfoService;

    /**
     * 查询
     * @return
     */
    @GetMapping("/get/page")
    public Result<ResultPage<UserInterfaceInfo>> getInterfaceInfoPage(UserInterfaceInfoQueryDTO UserInterfaceInfoQueryDTO){
        ResultPage<UserInterfaceInfo> res =  userInterfaceInfoService.getUserInterfaceInfoPage(UserInterfaceInfoQueryDTO);
        return Result.success(res);
    }

    /**
     * 查询根据id
     * @return
     */
    @GetMapping("/get/one")
    public Result<UserInterfaceInfo> getInterfaceById(Integer id){
        UserInterfaceInfo  res = userInterfaceInfoService.getUserInterfaceinfoById(id);
        return Result.success(res);
    }


    /**
     * 添加
     * @return
     */
    @PostMapping("/add")
    public Result addInterfaceInfo(@RequestBody UserInterfaceInfoAddDTO userInterfaceInfoAddDTO){
        userInterfaceInfoService.addUserInterfaceInfo(userInterfaceInfoAddDTO);
        return Result.success();
    }

    /**
     * 更新
     * @return
     */
    @GetMapping("/update")
    public Result updateInterfaceInfo(@RequestBody UserInterfaceInfoUpdateDTO userInterfaceInfoUpdateDTO){
        userInterfaceInfoService.updateUserInterfaceInfo(userInterfaceInfoUpdateDTO);
        return Result.success();
    }


    /**
     * 删除
     * @return
     */
    @GetMapping("/delete")
    public Result deleteInterfaceInfo(Integer id){
        userInterfaceInfoService.deleteUserInterfaceInfo(id);
        return Result.success();
    }
}
